package org.finesys.system.api.feign;

import org.finesys.common.constants.SecurityConstants;
import org.finesys.common.constants.ServerConstants;
import org.finesys.common.core.module.R;
import org.finesys.common.feign.annotation.NoToken;
import org.finesys.system.api.dto.SysUserDTO;
import org.finesys.system.api.dto.UserGiteeDto;
import org.finesys.system.api.dto.UserInfo;
import org.finesys.system.api.service.UserGiteeService;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

@FeignClient(contextId = "userGiteeServiceApi", value = ServerConstants.SYSTEM_SERVER)
public interface UserGiteeServiceApi extends UserGiteeService {

    /**
     * 添加
     */
    @PostMapping(value = "/gitee/add", headers = SecurityConstants.HEADER_INNER)
    R<Boolean> add(@RequestBody UserGiteeDto userGiteeDto);

    /**
     * 更新
     */
    @PostMapping(value = "/gitee/update", headers = SecurityConstants.HEADER_INNER)
    R<Boolean> update(@RequestBody UserGiteeDto userGiteeDto);

    /**
     * 绑定
     */
    @PostMapping(value = "/gitee/binding", headers = SecurityConstants.HEADER_INNER)
    R<Boolean> binding(@RequestBody UserGiteeDto userGiteeDto);

    /***
     * 根据AppId、id查询
     */
    @GetMapping(value = "/gitee/getByAppidAndId", headers = SecurityConstants.HEADER_INNER)
    R<UserGiteeDto> getByAppIdAndId(@RequestParam("appId") String appId, @RequestParam(value = "id") Long id);

    /**
     * 获取绑定用户信息
     */
    @GetMapping(value = "/gitee/getUser", headers = SecurityConstants.HEADER_INNER)
    R<SysUserDTO> getUser(@RequestParam(value = "appId") String appId, @RequestParam(value = "id") Long id);

    /**
     * 通过用户名查找用户信息
     *
     * @param userGiteeDto 用户信息
     * @return 用户信息
     */
    @NoToken
    @GetMapping("/gitee/info/query")
    R<UserInfo> info(UserGiteeDto userGiteeDto);
}
